var a = getApp();

Page({
    data: {
        page: 1,
        contenTapMore: !1
    },
    onLoad: function(t) {
        if (t.id && this.setData({
            id: t.id
        }), t.scene) {
            var e = decodeURIComponent(t.scene);
            if (e) {
                var i = [];
                i = e.split(",");
                for (var o = 0; o < i.length; o++) {
                    var n;
                    "mid" == (n = i[o].split("="))[0] && a._setMid(n[1]), "id" == n[0] && this.setData({
                        id: n[1]
                    });
                }
            }
        }
        wx.setNavigationBarTitle({
            title: "期刊杂志"
        }), this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (!(this.data.current_page >= this.data.last_page)) {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.getMore();
        }
    },
    onShareAppMessage: function() {
        var a = wx.getStorageSync("yz_uid"), t = "";
        return a && (t = a), {
            title: this.data.dinfo.title,
            path: "/packageH/article/periodicalDetail/periodicalDetail?id=" + this.data.id + "&mid=" + t,
            imageUrl: this.data.dinfo.cover
        };
    },
    tapMoreIcon: function(a) {
        var t = a.currentTarget.dataset.key;
        console.log(t), this.setData({
            contenTapMore: "1" != t
        });
    },
    goHome: function(a) {
        wx.reLaunch({
            url: "/packageH/article/periodicalIndex/periodicalIndex"
        });
    },
    goWatch: function(a) {
        console.log(a.currentTarget.dataset.ind);
        var t = a.currentTarget.dataset.ind;
        wx.navigateTo({
            url: "/packageH/article/periodicalWatch/periodicalWatch?id=" + this.data.id + "&ind=" + t
        });
    },
    getData: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.journal.frontend.journal.directory");
        a._postNetWork({
            url: e,
            data: {
                journal_id: t.data.id,
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                wx.hideLoading({
                    success: function(a) {}
                }), 1 == e.result ? (console.log(e), t.setData({
                    datas: e.data.directory.data,
                    info: e.data,
                    dinfo: e.data.info,
                    current_page: e.data.directory.current_page,
                    last_page: e.data.directory.last_page,
                    contenTapMore: !(e.data.info.overview.length >= 100)
                })) : console.log(e);
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    getMore: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.journal.frontend.journal.directory");
        a._postNetWork({
            url: e,
            data: {
                journal_id: t.data.id,
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                wx.hideLoading({
                    success: function(a) {}
                }), 1 == e.result && t.setData({
                    datas: t.data.datas.concat(e.data.directory.data),
                    current_page: e.data.directory.current_page,
                    last_page: e.data.directory.last_page
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    }
});